jQuery(document).ready(function($){
	var dates = $( "#searchFromDate, #searchToDate" ).datepicker({
		dateFormat: "yy-mm-dd",
		showOn: 'both',
		buttonImage: 'calanderimg',
		buttonImageOnly: true,
		buttonText: 'Choose',
		defaultDate: "+0w",
		numberOfMonths: 1,
		onSelect: function( selectedDate ) {
			var option = this.id == "searchFromDate" ? "minDate" : "maxDate",
				instance = $( this ).data( "datepicker" );
				date = $.datepicker.parseDate(
					instance.settings.dateFormat ||
					$.datepicker._defaults.dateFormat,
					selectedDate, instance.settings );
			dates.not( this ).datepicker( "option", option, date );
		}
	});

	$("a.fancybox").fancybox({
		'overlayShow'	: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});
});

function getAjaxOrderStatus(id,mode)
{
	var prod = id;
	var st = mode;
		
	jQuery.post(ajaxurl,{status:st,id:prod},function(data)
	 {		
		if(document.getElementById("order_status")){
			show_hide_span(id,0,data);
		}
	 });
}

function show_hide_span(ID,type,val)
{
	if(type==1){
		document.getElementById('span_'+ID).style.display='';
		document.getElementById('div_'+ID).style.display='none';
	}else{
		document.getElementById('span_'+ID).style.display='none';
		document.getElementById('div_'+ID).style.display='';
		document.getElementById('div_'+ID).innerHTML=val;
	}
}

function editProject(project_id,userid)
{
	if(project_id >0 && userid>0){
			var url = 'producturl'+project_id+'/'+userid+'/';
			//document.printfrm.project_id.value = project_id;
			//document.printfrm.userid.value = userid;
			eval("page" + project_id + " = window.open('"+url+"', 'designlab', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width="+window.width+",height="+window.height+",left =0,top = 0');");
	}else{
		alert("No Project Found!!");
	}
}

function refreshSearchOption(val)
{	
	if(val=='custom'){
		document.getElementById('custom_range_tr').style.display='';
	}else{
		document.getElementById('searchDateOption').value=val;
		document.getElementById('custom_range_tr').style.display='none';
	}
}